package main

import (
	"fmt"
	"sync/atomic"
	"unsafe"
)

func main() {
	var n int32
	x := atomic.AddInt32(&n, 10)
	fmt.Println(x, n)
	atomic.StoreInt32(&n, 1)
	fmt.Println(n)
	var y unsafe.Pointer
	s := 2
	var z unsafe.Pointer = unsafe.Pointer(&s)
	atomic.StorePointer(&y, z)
	xxx := *(*int)(y)
	fmt.Println(xxx)

	var zz int32
	old := atomic.SwapInt32(&zz, 11)
	fmt.Println(old, zz)
	ok := atomic.CompareAndSwapInt32(&zz, 10, 29)
	fmt.Println(ok, zz)
}
